package debux.apps.mltr.app;

import debux.apps.mltr.model.SongInfo;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class SongDetailsAcitivity extends Activity {
	TextView textViewName;
	TextView textViewLength;
	TextView textViewLink;
	TextView textViewLyrics;
	
	public static SongInfo songInfo;
	@Override
	public void onCreate(Bundle bundle){
		super.onCreate(bundle);
		setContentView(R.layout.song_details);
		textViewName = (TextView) findViewById(R.id.textViewName);
		textViewLength = (TextView) findViewById(R.id.textViewLength);
		textViewLink = (TextView) findViewById(R.id.textViewLink);
		textViewLyrics = (TextView) findViewById(R.id.textViewLyrics);

		if (songInfo!=null){
			textViewName.setText(songInfo.getName());
			textViewLength.setText(songInfo.getLength());
			//textViewLink.setText(songInfo.getLink());
			textViewLink.setOnClickListener(new OnClickListener() {			
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					String url = songInfo.getLink();					
					if (!url.startsWith("http://") && !url.startsWith("https://"))
						   url = "http://" + url;
				    Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
				    startActivity(myIntent);
				}
			});
			textViewLyrics.setText(songInfo.getLyrics());
		}
	}
}
